﻿#region Using directives

using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using NetROS.Tiers.Entities;
using NetROS.Tiers.Data;

#endregion

namespace NetROS.Tiers.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="VwBlagajnaSaldoProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract class VwBlagajnaSaldoProviderBaseCore : EntityViewProviderBase<VwBlagajnaSaldo>
	{
		#region Custom Methods
		
		
		#region _vwBlagajnaSaldo_SaldoDoDatuma
		
		/// <summary>
		///	This method wrap the '_vwBlagajnaSaldo_SaldoDoDatuma' stored procedure. 
		/// </summary>
		/// <param name="DatumOd"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="IDBlagajne"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="VList&lt;VwBlagajnaSaldo&gt;"/> instance.</returns>
		public VList<VwBlagajnaSaldo> SaldoDoDatuma(System.DateTime? @DatumOd, System.Int32? @IDBlagajne)
		{
			return SaldoDoDatuma(null, 0, int.MaxValue , @DatumOd, @IDBlagajne);
		}
		
		/// <summary>
		///	This method wrap the '_vwBlagajnaSaldo_SaldoDoDatuma' stored procedure. 
		/// </summary>
		/// <param name="DatumOd"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="IDBlagajne"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="VList&lt;VwBlagajnaSaldo&gt;"/> instance.</returns>
		public VList<VwBlagajnaSaldo> SaldoDoDatuma(int start, int pageLength, System.DateTime? @DatumOd, System.Int32? @IDBlagajne)
		{
			return SaldoDoDatuma(null, start, pageLength , @DatumOd, @IDBlagajne);
		}
				
		/// <summary>
		///	This method wrap the '_vwBlagajnaSaldo_SaldoDoDatuma' stored procedure. 
		/// </summary>
		/// <param name="DatumOd"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="IDBlagajne"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <returns>A <see cref="VList&lt;VwBlagajnaSaldo&gt;"/> instance.</returns>
		public VList<VwBlagajnaSaldo> SaldoDoDatuma(TransactionManager transactionManager, System.DateTime? @DatumOd, System.Int32? @IDBlagajne)
		{
			return SaldoDoDatuma(transactionManager, 0, int.MaxValue , @DatumOd, @IDBlagajne);
		}
		
		/// <summary>
		///	This method wrap the '_vwBlagajnaSaldo_SaldoDoDatuma' stored procedure. 
		/// </summary>
		/// <param name="DatumOd"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="IDBlagajne"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="VList&lt;VwBlagajnaSaldo&gt;"/> instance.</returns>
		public abstract VList<VwBlagajnaSaldo> SaldoDoDatuma(TransactionManager transactionManager, int start, int pageLength , System.DateTime? @DatumOd, System.Int32? @IDBlagajne);
		
		#endregion
		
		#endregion

		#region Helper Functions
		
		/*
		///<summary>
		/// Fill an VList&lt;VwBlagajnaSaldo&gt; From a DataSet
		///</summary>
		/// <param name="dataSet">the DataSet</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Start row</param>
		/// <param name="pagelen">number of row.</param>
		///<returns><see chref="VList&lt;VwBlagajnaSaldo&gt;"/></returns>
		protected static VList&lt;VwBlagajnaSaldo&gt; Fill(DataSet dataSet, VList<VwBlagajnaSaldo> rows, int start, int pagelen)
		{
			if (dataSet.Tables.Count == 1)
			{
				return Fill(dataSet.Tables[0], rows, start, pagelen);
			}
			else
			{
				return new VList<VwBlagajnaSaldo>();
			}	
		}
		
		
		///<summary>
		/// Fill an VList&lt;VwBlagajnaSaldo&gt; From a DataTable
		///</summary>
		/// <param name="dataTable">the DataTable that hold the data.</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Start row</param>
		/// <param name="pagelen">number of row.</param>
		///<returns><see chref="VList<VwBlagajnaSaldo>"/></returns>
		protected static VList&lt;VwBlagajnaSaldo&gt; Fill(DataTable dataTable, VList<VwBlagajnaSaldo> rows, int start, int pagelen)
		{
			int recordnum = 0;
			
			System.Collections.IEnumerator dataRows =  dataTable.Rows.GetEnumerator();
			
			while (dataRows.MoveNext() && (pagelen != 0))
			{
				if(recordnum >= start)
				{
					DataRow row = (DataRow)dataRows.Current;
				
					VwBlagajnaSaldo c = new VwBlagajnaSaldo();
					c.ID = (Convert.IsDBNull(row["ID"]))?(int)0:(System.Int32)row["ID"];
					c.Saldo = (Convert.IsDBNull(row["Saldo"]))?0:(System.Decimal?)row["Saldo"];
					c.AcceptChanges();
					rows.Add(c);
					pagelen -= 1;
				}
				recordnum += 1;
			}
			return rows;
		}
		*/	
						
		///<summary>
		/// Fill an <see cref="VList&lt;VwBlagajnaSaldo&gt;"/> From a DataReader.
		///</summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Start row</param>
		/// <param name="pageLength">number of row.</param>
		///<returns>a <see cref="VList&lt;VwBlagajnaSaldo&gt;"/></returns>
		protected VList<VwBlagajnaSaldo> Fill(IDataReader reader, VList<VwBlagajnaSaldo> rows, int start, int pageLength)
		{
			int recordnum = 0;
			while (reader.Read() && (pageLength != 0))
			{
				if(recordnum >= start)
				{
					VwBlagajnaSaldo entity = null;
					if (DataRepository.Provider.UseEntityFactory)
					{
						entity = EntityManager.CreateViewEntity<VwBlagajnaSaldo>("VwBlagajnaSaldo",  DataRepository.Provider.EntityCreationalFactoryType); 
					}
					else
					{
						entity = new VwBlagajnaSaldo();
					}
					entity.ID = (System.Int32)reader["ID"];
					//entity.ID = (Convert.IsDBNull(reader["ID"]))?(int)0:(System.Int32)reader["ID"];
					entity.Saldo = reader.IsDBNull(reader.GetOrdinal("Saldo")) ? null : (System.Decimal?)reader["Saldo"];
					//entity.Saldo = (Convert.IsDBNull(reader["Saldo"]))?0:(System.Decimal?)reader["Saldo"];
					entity.AcceptChanges();
					rows.Add(entity);
					pageLength -= 1;
				}
				recordnum += 1;
			}
			return rows;
		}
		
		
		/// <summary>
		/// Refreshes the <see cref="VwBlagajnaSaldo"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="VwBlagajnaSaldo"/> object to refresh.</param>
		protected void RefreshEntity(IDataReader reader, VwBlagajnaSaldo entity)
		{
			reader.Read();
			entity.ID = (System.Int32)reader["ID"];
			//entity.ID = (Convert.IsDBNull(reader["ID"]))?(int)0:(System.Int32)reader["ID"];
			entity.Saldo = reader.IsDBNull(reader.GetOrdinal("Saldo")) ? null : (System.Decimal?)reader["Saldo"];
			//entity.Saldo = (Convert.IsDBNull(reader["Saldo"]))?0:(System.Decimal?)reader["Saldo"];
			reader.Close();
	
			entity.AcceptChanges();
		}
		
		/*
		/// <summary>
		/// Refreshes the <see cref="VwBlagajnaSaldo"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="VwBlagajnaSaldo"/> object.</param>
		protected static void RefreshEntity(DataSet dataSet, VwBlagajnaSaldo entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.ID = (Convert.IsDBNull(dataRow["ID"]))?(int)0:(System.Int32)dataRow["ID"];
			entity.Saldo = (Convert.IsDBNull(dataRow["Saldo"]))?0:(System.Decimal?)dataRow["Saldo"];
			entity.AcceptChanges();
		}
		*/
			
		#endregion Helper Functions
	}//end class

	#region VwBlagajnaSaldoFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="VwBlagajnaSaldo"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class VwBlagajnaSaldoFilterBuilder : SqlFilterBuilder<VwBlagajnaSaldoColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the VwBlagajnaSaldoFilterBuilder class.
		/// </summary>
		public VwBlagajnaSaldoFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the VwBlagajnaSaldoFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public VwBlagajnaSaldoFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the VwBlagajnaSaldoFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public VwBlagajnaSaldoFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion VwBlagajnaSaldoFilterBuilder

	#region VwBlagajnaSaldoParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="VwBlagajnaSaldo"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class VwBlagajnaSaldoParameterBuilder : ParameterizedSqlFilterBuilder<VwBlagajnaSaldoColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the VwBlagajnaSaldoParameterBuilder class.
		/// </summary>
		public VwBlagajnaSaldoParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the VwBlagajnaSaldoParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public VwBlagajnaSaldoParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the VwBlagajnaSaldoParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public VwBlagajnaSaldoParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion VwBlagajnaSaldoParameterBuilder
} // end namespace
